﻿@{
    var tableName = PageViewModel.PageTableID(this);

    var dir_list_id = PageViewModel.ControlID(this, "dir_list");
    var dir_list_fmt = PageViewModel.ControlID(this, "dir_list_fmt");
    var dir_list_load_success = PageViewModel.ControlID(this, "dir_list_load_success");
    var on_dir_selected = PageViewModel.ControlID(this, "on_dir_selected");
}
<style type="text/css">
    #layout_@dir_list_id{ }
    #layout_@dir_list_id .panel-header {
        height:41px;
        background-color:#fdfdfd;
        text-align:center;
    }
</style>

<script type="text/javascript">
    function @dir_list_fmt (v, r, i) {
        return "<div style='padding-left:10px;padding-right:10px;height:35px;line-height:35px;cursor:pointer;'>" + r.Name + "</div>";
    }

    function @on_dir_selected (index, row) {
        if (row != null) {
            $.ajax({
                url: "~/Systems/GetAppDictionarys?typeCode="+row.Code,
                type: "GET",
                success: function (e) {
                    $("#@tableName").datagrid("loadData", e);
                },
                error: function (e) {
                    ShowAjaxError(e);
                }
            });
        }
    }

    function @dir_list_load_success (data) {
        if (data.rows.length > 0) {
            $("#@dir_list_id").datalist("selectRow", 0);
        }
    }

</script>
<ul id="@dir_list_id" class="easyui-datalist" title="类别" fit="true" data-options="border:false,lines:true,
                                                                                  url: '~/Systems/GetAppDictionarys',method:'get',
                                                                                  textField:'Name',valueField:'DictionaryID',selectOnCheck:false,
                                                                                  textFormatter:@dir_list_fmt,
                                                                                  onSelect:@on_dir_selected,
                                                                                  onLoadSuccess:@dir_list_load_success"></ul>
